#include "ej_fm1505_control.h"
#include "ej_fm1505_phy.h"
#include "board_includes.h"
#include "common_includes.h"
#include "drv_dsp.h"
#ifdef SUPPORT_FM1505_DMS
static fm1505_word_mode_e g_fm1505_cur_mode = FM1505_MODE_STANDBY;

void ej_fm1505_control(uint8_t cmd, uint8_t param)
{
	switch (cmd)
	{
		case FM1505_CMD_RESET:
		{
			dsp_hw_reset();
			break;
		}

		case FM1505_CMD_SWITCH_TO_STANDBY_MODE:
		{
			if(dsp_switch_mode(dsp_mode2))
			{
				printf("dsp_switch dsp_mode2 successfully!\n");
				g_fm1505_cur_mode = FM1505_MODE_STANDBY;
			}
			else
			{
				printf("dsp_switch dsp_mode2 failed!\n");
			}
			break;
		}

		case FM1505_CMD_SWITCH_TO_WORKING_MODE:
		{
			if(dsp_switch_mode(dsp_mode1))
			{
				printf("dsp_switch dsp_mode1 successfully!\n");
				g_fm1505_cur_mode = FM1505_MODE_WORKING;
			}
			else
			{
				printf("dsp_switch dsp_mode1 failed!\n");
			}
			break;
		}

		default:break;
	}
}

fm1505_word_mode_e ej_fm1505_get_mode(void)
{
	return g_fm1505_cur_mode;
}

void ej_fm1505_init(void)
{
	ej_fm1505_phy_init();

	if (dsp_init())
	{
		printf("dsp initialization and startup successfully!\n");
	}
	else
	{
		printf("dsp initialization and startup failed!\n");
	}
}

void ej_fm1505_exit(void)
{
	ej_fm1505_phy_exit();
}

#endif
